<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePromotionUserFlowTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('promotion_user_flow', function (Blueprint $table) {
            $table->increments('id');
            $table->string('user_id', 20)->default('')->comment('用户ID');
            $table->string('shop_id', 20)->default('')->comment('商户ID');
            $table->string('order_num')->default('')->comment('订单号');
            $table->json('info')->default('')->comment('流水详情');
            $table->decimal('amount', 38, 4)->default(0)->comment('实际收到');
            $table->decimal('should', 38, 4)->default(0)->comment('应该收到');
            $table->decimal('platform', 38, 4)->default(0)->comment('平台扣除');
            $table->decimal('history', 38, 4)->default(0)->comment('历史');
            $table->integer('plan_id')->default(0)->comment('推广计划ID');
            $table->enum('read', ['true', 'false'])->default('false')->comment('读取');
            $table->integer('create_time')->default(0)->comment('创建时间');
            $table->integer('update_time')->default(0)->comment('更新时间');
            $table->index('shop_id');
            $table->index('user_id');
            $table->index('order_num');
            $table->index('plan_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('promotion_user_flow');
    }
}
